home *** CD-ROM | disk | FTP | other *** search
/ MacWarehouse Macintosh Games / MacWarehouse Macintosh Games.iso / AMBER demo / ROXY / ROXY.dxr / 00001_generic domain rules.ls next >
Encoding:
Text File  |  1996-10-18  |  13.4 KB  |  450 lines

  1. on cursorOff
  2.   global colorcrsr, YugoCursors, gCursorSwitch
  3.   if objectp(colorcrsr) then
  4.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  5.     set gCursorSwitch to #off
  6.   else
  7.     cursor(200)
  8.     set gCursorSwitch to #off
  9.   end if
  10. end
  11.  
  12. on cursorOn
  13.   global colorcrsr, YugoCursors, thisCursor, gCursorSwitch
  14.   if gCursorSwitch = #off then
  15.     if objectp(colorcrsr) then
  16.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  17.     else
  18.       castCursor(getProp(YugoCursors, thisCursor))
  19.     end if
  20.     set gCursorSwitch to #on
  21.   end if
  22. end
  23.  
  24. on setCursorQuality recommendation
  25.   global oPuppeteer
  26.   set the cursorQuality of oPuppeteer to recommendation
  27. end
  28.  
  29. on castCursor cursorID
  30.   set myCursorOffset to 2500
  31.   if integerp(cursorID) then
  32.     set whichCursor to cursorID - 6000
  33.   else
  34.     put "castCursor(): wow, a cursor label: "
  35.     put cursorID
  36.     exit
  37.   end if
  38.   set cMask to myCursorOffset + (whichCursor * 2)
  39.   cursor([cMask - 1, cMask])
  40. end
  41.  
  42. on killVideo
  43.   global lastScoreSprite
  44.   set vidSprite to 44
  45.   set the movieRate of sprite vidSprite to 0
  46.   set the locV of sprite vidSprite to -500
  47.   updateStage()
  48.   set the castNum of sprite vidSprite to 7
  49.   puppetSprite(vidSprite, 0)
  50. end
  51.  
  52. on pushVideo
  53.   set vidSprite to 44
  54.   set the movieTime of sprite 44 to 0
  55.   updateStage()
  56.   set the movieRate of sprite 44 to 1
  57.   repeat while the movieRate of sprite 44 <> 1
  58.     updateStage()
  59.   end repeat
  60. end
  61.  
  62. on setCurrentLocation suggestion
  63.   return "Use the goTo() function instead.."
  64. end
  65.  
  66. on goTo destination, transition
  67.   global oPuppeteer, oStoryteller, builderWindow, gPreloading, gScanFinish, colorcrsr, YugoCursors, thisCursor, gCursorSwitch, gPeekAlertEnabled
  68.   if objectp(colorcrsr) then
  69.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  70.   else
  71.     cursor(200)
  72.   end if
  73.   set gCursorSwitch to #off
  74.   if (destination = #destination) or (transition = #transition) then
  75.     exit
  76.   end if
  77.   setAt(getProp(the lsStateData of oStoryteller, #previousLocation), 1, getAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1))
  78.   setAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1, destination)
  79.   if the castNum of sprite 44 <> 7 then
  80.     killVideo()
  81.     moveMovies(oPuppeteer)
  82.   end if
  83.   if transition <> 0 then
  84.     setTransition(oPuppeteer, transition)
  85.   end if
  86.   moveToLocation(oPuppeteer)
  87.   if getPos(the windowList, builderWindow) then
  88.     tell builderWindow
  89.       refreshCast()
  90.       refreshHotspots()
  91.     end tell
  92.   end if
  93.   if gPreloading = 1 then
  94.     preloadLocations()
  95.   else
  96.   end if
  97.   set lsMoveCounter to getProp(the lsStateData of oStoryteller, #moveCount)
  98.   set oldCount to getAt(lsMoveCounter, 1)
  99.   setAt(lsMoveCounter, 1, oldCount + 1)
  100.   if (getState(oStoryteller, #playerHasPeekUnit) <> 0) and gPeekAlertEnabled then
  101.     if (gScanFinish <> 0) and (the ticks > gScanFinish) then
  102.       setState(oStoryteller, #PKscanStatus, #ReadyForPlayback)
  103.       setState(oStoryteller, #PeekDisplay, #scanStatus)
  104.       set gScanFinish to 0
  105.     end if
  106.     if getState(oStoryteller, #BarOnline) and (getState(oStoryteller, #PeekDisplay) = #none) then
  107.       set showTime to getState(oStoryteller, #hauntDelay)
  108.       if (getAt(lsMoveCounter, 1) > showTime) and (destination <> #LivingRmBarCU2) then
  109.         spawnGhostlyEvent()
  110.         setProp(the lsStateData of oStoryteller, #hauntDelay, [12])
  111.       end if
  112.     end if
  113.     if getState(oStoryteller, #PeekDisplay) <> #none then
  114.       peekAlert()
  115.       setAt(lsMoveCounter, 1, 0)
  116.     end if
  117.   end if
  118.   return #OK
  119. end
  120.  
  121. on goBack
  122.   global oStoryteller
  123.   goTo(getState(oStoryteller, #previousLocation), #backOff)
  124. end
  125.  
  126. on idle
  127.   global lastCursor, thisCursor, cursorOffset, castCursorList, maxCursor, gClickLoc, oStoryteller, oPuppeteer, gCurrentHotspot, gItemInUse, domainIsReady, gPreloading, gStopTransitions, g16bit, gTransQuality, gFreezeInventory, gSoundPath, gOriginPoint, gMenuBottomY, gInventoryTopY, gGammaLevel, gDeferredTransit, gripple
  128.   if gDeferredTransit = #none then
  129.     if domainIsReady then
  130.       cursorOn()
  131.       if getState(oStoryteller, #itemInUse) = #none then
  132.         set thisCursor to #pointer
  133.       else
  134.         set thisCursor to getState(oStoryteller, #itemInUse)
  135.       end if
  136.       set gCurrentHotspot to #none
  137.       if the mouseV < gMenuBottomY then
  138.         if the number of menus = 0 then
  139.           installMenu(14)
  140.           if gTransQuality = #none then
  141.             set the checkMark of menuItem 1 of menu 3 to 1
  142.           end if
  143.           if gTransQuality = #Better then
  144.             set the checkMark of menuItem 2 of menu 3 to 1
  145.           end if
  146.           if gTransQuality = #Best then
  147.             set the checkMark of menuItem 3 of menu 3 to 1
  148.           end if
  149.           set the checkMark of menuItem (8 - the soundLevel) of menu 2 to 1
  150.           if gGammaLevel <> "unknown" then
  151.             set the checkMark of menuItem (8 - gGammaLevel) of menu 4 to 1
  152.           end if
  153.           set thisCursor to #pointer
  154.         end if
  155.       else
  156.         installMenu(0)
  157.       end if
  158.       if not gFreezeInventory then
  159.         if the mouseV > gInventoryTopY then
  160.           if the inventoryStatus of oPuppeteer = #cool then
  161.             set the inventoryStatus of oPuppeteer to #hot
  162.             updateInventory()
  163.             updateStage()
  164.           end if
  165.         else
  166.           if (the inventoryStatus of oPuppeteer = #hot) and (gClickLoc = #none) then
  167.             set the inventoryStatus of oPuppeteer to #cool
  168.             updateInventory()
  169.             updateStage()
  170.           end if
  171.         end if
  172.       end if
  173.       if listp(gClickLoc) then
  174.         set mouseLoc to gClickLoc - gOriginPoint
  175.       else
  176.         set mouseLoc to point(the mouseH, the mouseV) - gOriginPoint
  177.       end if
  178.       repeat with i in the lsLiveHotspots of oPuppeteer
  179.         if inside(mouseLoc, getAt(i, 2)) then
  180.           set myCursor to getAt(i, 1)
  181.           if myCursor = #itemInUse then
  182.             set thisCursor to getState(oStoryteller, #itemInUse)
  183.           else
  184.             set thisCursor to myCursor
  185.           end if
  186.           set gCurrentHotspot to i
  187.           exit repeat
  188.         end if
  189.       end repeat
  190.       if getState(oStoryteller, #itemInUse) = #none then
  191.         if (the mouseCast = getProp(the lsForegroundData of oPuppeteer, #Headgear)) or (the mouseCast = getProp(the lsForegroundData of oPuppeteer, #HeadgearOff)) then
  192.           set thisCursor to #pointer
  193.         end if
  194.       end if
  195.       if (gCurrentHotspot = #none) and (the inventoryStatus of oPuppeteer = #hot) then
  196.         set whichSlot to 1
  197.         repeat with i in [rect(77, 377, 144, 444), rect(147, 377, 214, 444), rect(217, 377, 284, 444), rect(287, 377, 354, 444), rect(357, 377, 424, 444), rect(427, 377, 494, 444), rect(497, 377, 564, 444)]
  198.           if inside(mouseLoc, i) then
  199.             set newItem to getAt(the lsInventory of oPuppeteer, whichSlot)
  200.             if newItem <> #none then
  201.               set gCurrentHotspot to [0, 0, ["useInventory(#" & newItem & ")"]]
  202.             end if
  203.             exit repeat
  204.             next repeat
  205.           end if
  206.           set whichSlot to whichSlot + 1
  207.         end repeat
  208.       end if
  209.       if thisCursor <> lastCursor then
  210.         if the movieRate of sprite 44 = 0 then
  211.           cursorDance(value(lastCursor & "To" & thisCursor))
  212.         else
  213.           cursorDance(0)
  214.         end if
  215.         set lastCursor to thisCursor
  216.       end if
  217.       if getState(oStoryteller, #BT_fragStatus) = #spinningNow then
  218.         refreshAlignmentPuzzle()
  219.       end if
  220.       if gripple then
  221.         if the castNum of sprite 44 = 7 then
  222.           ripple()
  223.         end if
  224.       end if
  225.     end if
  226.     if listp(gClickLoc) then
  227.       set gClickLoc to #none
  228.     end if
  229.     if the lastEvent > (120 * 60) then
  230.       returnToSlideshow()
  231.     end if
  232.   else
  233.     do(gDeferredTransit)
  234.     if gDeferredTransit contains "waiting" then
  235.       if domainIsReady = 1 then
  236.         if getState(oStoryteller, #currentDomain) = the last word in gDeferredTransit then
  237.           set gDeferredTransit to #none
  238.         end if
  239.       end if
  240.     end if
  241.   end if
  242. end
  243.  
  244. on cursorDance cursorList
  245.   global colorcrsr, thisCursor, YugoCursors, gCPU
  246.   if gCPU <> #PC then
  247.     if not objectp(colorcrsr) then
  248.       cursor(-1)
  249.       set colorcrsr to ColorCursor(mnew)
  250.     end if
  251.   end if
  252.   if not listp(cursorList) then
  253.     if objectp(colorcrsr) then
  254.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  255.     else
  256.       castCursor(getProp(YugoCursors, thisCursor))
  257.     end if
  258.     exit
  259.   end if
  260.   set flipBook to cursorList
  261.   if objectp(colorcrsr) then
  262.     repeat with flipper = 1 to count(flipBook)
  263.       startTimer()
  264.       colorcrsr(mGetSetCursor, getAt(flipBook, flipper))
  265.       repeat while 2 > the timer
  266.         nothing()
  267.       end repeat
  268.     end repeat
  269.   else
  270.     repeat with flipper = 1 to count(flipBook)
  271.       startTimer()
  272.       castCursor(getAt(flipBook, flipper))
  273.       repeat while 2 > the timer
  274.         nothing()
  275.       end repeat
  276.     end repeat
  277.   end if
  278. end
  279.  
  280. on inState stateVar, whichItem
  281.   global oStoryteller
  282.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  283.   return getPos(statelist, whichItem)
  284. end
  285.  
  286. on trimState stateVar, whichItem
  287.   global oStoryteller
  288.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  289.   set myPos to getPos(statelist, whichItem)
  290.   if myPos then
  291.     deleteAt(statelist, myPos)
  292.   end if
  293. end
  294.  
  295. on addState stateVar, whichItem
  296.   global oStoryteller
  297.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  298.   set myPos to getPos(statelist, whichItem)
  299.   if not myPos then
  300.     append(statelist, whichItem)
  301.   end if
  302. end
  303.  
  304. on patchPalette
  305.   global oFixPal
  306.   oFixPal(mPatchIt)
  307. end
  308.  
  309. on forcePalette palName
  310.   global oPuppeteer, gCurrentPalette
  311.   puppetPalette(palName, 60)
  312.   set gCurrentPalette to #changeMe
  313.   patchPalette()
  314. end
  315.  
  316. on loadMultiFrames whichOnes
  317.   global oPuppeteer
  318.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  319.   if listp(theFrames) then
  320.     repeat with i in theFrames
  321.       preLoadCast(i)
  322.     end repeat
  323.   else
  324.     alert("Hey! There's no such list in lsMultiframes!")
  325.   end if
  326. end
  327.  
  328. on purgeMultiframes whichOnes
  329.   global oPuppeteer
  330.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  331.   if listp(theFrames) then
  332.     repeat with i in theFrames
  333.       unLoadCast(i)
  334.     end repeat
  335.   else
  336.     alert("Hey! There's no such list in lsMultiframes!")
  337.   end if
  338. end
  339.  
  340. on gammaFade upOrDown, howFast
  341.   global gCPU
  342.   if gCPU = #PC then
  343.     exit
  344.   end if
  345.   set speedCodes to [#glacial: "4", #slow: "18", #fast: "36", #instant: "100"]
  346.   set mySpeed to getaProp(speedCodes, howFast)
  347.   if voidp(mySpeed) then
  348.     set mySpeed to getProp(speedCodes, #fast)
  349.   end if
  350.   if upOrDown = #down then
  351.     MonitorFade("down", mySpeed)
  352.   else
  353.     updateStage()
  354.     MonitorFade("up", mySpeed)
  355.   end if
  356. end
  357.  
  358. on fadeTest
  359.   gammaFade(#down)
  360.   wait(15)
  361.   gammaFade(#up, #glacial)
  362. end
  363.  
  364. on setColor howManybits
  365.   set the colorDepth to howManybits
  366.   if the colorDepth <> howManybits then
  367.     put "Sorry, Director sez the colorDepth is " & the colorDepth & " bits.."
  368.   else
  369.     put "OK, we did it.."
  370.   end if
  371. end
  372.  
  373. on waitAsec startSwitch
  374.   global gSecStart
  375.   if voidp(gSecStart) then
  376.     set gSecStart to #idle
  377.   end if
  378.   if startSwitch = #start then
  379.     set gSecStart to the ticks
  380.     return #starting
  381.   else
  382.     set currentTime to the ticks
  383.     if currentTime > (gSecStart + 60) then
  384.       return #finished
  385.       set gSecStart to #idle
  386.     else
  387.       return #waiting
  388.     end if
  389.   end if
  390. end
  391.  
  392. on putDownThePhone
  393.   global oStoryteller, oPuppeteer
  394.   if (getState(oStoryteller, #phoneButtonsPressed) > 0) and inState(#hauntsRemaining, #spookyOperator) then
  395.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [7])
  396.     setState(oStoryteller, #ghostlyPhoneCall, #speaking)
  397.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [0])
  398.   else
  399.     setState(oStoryteller, #playerIsExaminingPhone, 0)
  400.     setState(oStoryteller, #ghostlyPhoneCall, #done)
  401.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [0])
  402.     setTransition(oPuppeteer, #fadeIn)
  403.   end if
  404.   updateDisplay(oPuppeteer)
  405. end
  406.  
  407. on updateInventory
  408.   global oPuppeteer, oStoryteller, gOriginPoint
  409.   set foundationSprite to 3
  410.   set itemV to 410
  411.   set itemH to 110
  412.   set itemInHand to getState(oStoryteller, #itemInUse)
  413.   set lsInventory to the lsInventory of oPuppeteer
  414.   set lsInventoryData to the lsInventoryData of oPuppeteer
  415.   if the inventoryStatus of oPuppeteer = #hot then
  416.     repeat with i = 1 to 7
  417.       set itemName to getAt(lsInventory, i)
  418.       set itemSprite to foundationSprite + i
  419.       if (itemName = #none) or (itemName = itemInHand) then
  420.         set the castNum of sprite itemSprite to 6
  421.         set the loc of sprite itemSprite to point(320, -360) + gOriginPoint
  422.       else
  423.         puppetSprite(itemSprite, 1)
  424.         set the castNum of sprite itemSprite to getAt(getProp(lsInventoryData, itemName), 1)
  425.         set the loc of sprite itemSprite to point(itemH, itemV) + gOriginPoint
  426.       end if
  427.       set itemH to itemH + 70
  428.     end repeat
  429.   else
  430.     repeat with i = 1 to 7
  431.       set itemName to getAt(lsInventory, i)
  432.       set itemSprite to foundationSprite + i
  433.       if (itemName = #none) or (itemName = itemInHand) then
  434.         set the castNum of sprite itemSprite to 6
  435.         set the loc of sprite itemSprite to point(320, -360) + gOriginPoint
  436.       else
  437.         puppetSprite(itemSprite, 1)
  438.         set the castNum of sprite itemSprite to getAt(getProp(lsInventoryData, itemName), 2)
  439.         set the loc of sprite itemSprite to point(itemH, itemV) + gOriginPoint
  440.       end if
  441.       set itemH to itemH + 70
  442.     end repeat
  443.   end if
  444. end
  445.  
  446. on stashClick
  447.   global gClickLoc
  448.   set gClickLoc to point(the mouseH, the mouseV)
  449. end
  450.